import { defineStore } from 'pinia'
import { siteConfigApi } from '@/api/common'

const useCommonStore = defineStore('commonStore', {
	state: (): any => {
		return {
			img_domain: '' // 请求图片根地址
		}
	},
	actions: {
		// 获取请求图片根地址
		async siteConfigAction() {
			const res = await siteConfigApi()
			if (res.code == 0) {
				const { img_domain } = res.result
				this.img_domain = img_domain
			}
		}
	},
	persist: {
		enabled: true, //开启持久化操作,默认全部字段存储，存储在sessionSotrage里面
		strategies: [{ storage: localStorage, paths: ['img_domain'] }]
	}
})

export default useCommonStore
